<script>
	export default {
		async onLaunch() {
			console.log('App Launch');
<<<<<<< HEAD
            /*
            let appEdition = await this.$u.api.appEdition({
                id: this.vuex_app_id || this.$config.app_id
            });
            if (!appEdition) {
                return this.$appLaunchReject({ message: '初始化失败' });
            }
            if (!this.vuex_app_edition || !Object.keys(this.vuex_app_edition).length) {
                uni.clearStorageSync();
                this.$u.vuex('vuex_app_edition', appEdition);
            }
            */
           let version = uni.getStorageSync('version');
           if (!version || parseInt(version) < 2) {
               uni.clearStorageSync();
               uni.setStorageSync('version', 2)
           }
           
            // 应用信息
            console.log('app-->vuex_app_info[获取缓存应用信息]:', this.vuex_app_info);
            if (!this.vuex_app_info || !Object.keys(this.vuex_app_info).length) {
                console.log('app-->apiappDetail[调用站点信息接口]:');
                let appDetail = await this.$u.api.appDetail({
                    id: this.vuex_app_id || this.$config.app_id
                });
                console.log('app-->apiappDetail[站点信息接口结果]:', appDetail);
                if (!appDetail) {
                    // 初始化失败
                    return this.$appLaunchReject({ message: '站点初始化失败' });
                }
                // 设置到本地存储
                this.$u.vuex('vuex_app_info', appDetail);
            }
            // 站点配置
            let appConfig = this.vuex_app_info.config;
            console.log('app-->appConfig[站点配置信息]:', appConfig);
            // 访问控制
            if (appConfig.common.view_client.indexOf(this.clientType) == -1) {
                // 禁止访问跳转到错误页
                return this.$appLaunchReject({ message: appConfig.common.view_client_disable_help });
            }
            // #ifdef H5
            if (this.clientType == 'wechat_mobile' || this.clientType == 'wechat_computer') {
                // 微信客户端
                // 验证登陆信息
                let loginInfo = this.$wx.loginCheckFunc(this.vuex_wx_id);
                // 更新全局信息
                if (loginInfo && (!this.vuex_wx_id || this.vuex_wx_id != loginInfo.id || !this.vuex_wx_token || this.vuex_wx_token != loginInfo.token)) {
                    this.$u.vuex('vuex_wx_id', loginInfo.id);
                    this.$u.vuex('vuex_wx_token', loginInfo.token);
                }
                console.log('app->vuex_wx_token[缓存微信TOKEN]:', this.vuex_wx_token);
                // region 微信SDK +++++
                let wxJsSdkConfig = await this.$u.api.wxJsSdkConfig({
                    wx_id: this.vuex_wx_id,
                    wx_sign_link: window.location.href
                });
                if (wxJsSdkConfig) {
                    console.log('app->wxShareConfig[微信jssdk配置]:', wxJsSdkConfig);
                    this.$wx.sdk.config(JSON.parse(wxJsSdkConfig));
                    this.$wx.sdk.ready(() => {
                        this.$wx.sdk.hideMenuItems({
                            menuList: ['menuItem:share:qq', 'menuItem:share:weiboApp', 'menuItem:favorite', 'menuItem:share:facebook', 'menuItem:share:QZone', 'menuItem:copyUrl', 'menuItem:openWithQQBrowser', 'menuItem:openWithSafari']
                        });
                        this.$wx.sdk.updateAppMessageShareData({
                            title: this.$config.wx_share_title,
                            desc: this.$config.wx_share_desc,
                            link: this.$config.wx_share_link,
                            imgUrl: this.$config.wx_share_image,
                            success: function() {
                                // 设置成功
                            }
                        });
                        this.$wx.sdk.updateTimelineShareData({
                            title: this.$config.wx_share_title,
                            link: this.$config.wx_share_link,
                            imgUrl: this.$config.wx_share_image,
                            success: function() {
                                // 设置成功
                            }
                        });
                        // 分享到朋友圈
                        this.$wx.sdk.onMenuShareTimeline({
                            title: this.$config.wx_share_title,
                            link: this.$config.wx_share_link,
                            imgUrl: this.$config.wx_share_image,
                            success: function() {
                                // 用户确认后执行的回调函数
                            },
                            cancel: function() {
                                // 用户取消后执行的回调函数
                            }
                        });
                        //分享给朋友
                        this.$wx.sdk.onMenuShareAppMessage({
                            title: this.$config.wx_share_title,
                            desc: this.$config.wx_share_desc,
                            link: this.$config.wx_share_link,
                            imgUrl: this.$config.wx_share_image,
                            type: 'link',
                            dataUrl: '',
                            success: function() {
                                // 用户确认后执行的回调函数
                            },
                            cancel: function() {
                                // 用户取消后执行的回调函数
                            }
                        });
                    });
                }
                // endregion
            }
            // #endif
            // 初始化完成
            this.$appLaunchResolve(true);
=======
			// region 应用版本处理 +++++
			/*
			let appEdition = await this.$u.api.appEdition({
				id: this.vuex_app_id || this.$config.app_id
			});
			if (!appEdition) {
				return this.$appLaunchReject({
					message: '应用初始化失败'
				});
			}
			if (!this.vuex_app_edition || !Object.keys(this.vuex_app_edition).length) {
				uni.clearStorageSync();
				this.$u.vuex('vuex_app_edition', appEdition);
			}
			let version = uni.getStorageSync('version');
			if (!version || parseInt(version) < 2) {
				uni.clearStorageSync();
				uni.setStorageSync('version', 2)
			}
			*/
			// endregion

			// 应用信息
			console.log('app-->vuex_app_info[获取缓存应用信息]:', this.vuex_app_info);
			if (!this.vuex_app_info || !Object.keys(this.vuex_app_info).length) {
				console.log('app-->apiAppDetail[调用应用信息接口]:');
				let appDetail = await this.$u.api.appDetail({
					id: this.vuex_app_id || this.$config.app_id
				});
				console.log('app-->apiAppDetail[应用信息接口结果]:', appDetail);
				if (!appDetail) {
					// 初始化失败
					return this.$appLaunchReject({
						message: '应用初始化失败'
					});
				}
				// 设置到本地存储
				this.$u.vuex('vuex_app_info', appDetail);
			}
			// 应用配置
			let appConfig = this.vuex_app_info.config;
			console.log('app-->appConfig[应用配置信息]:', appConfig);
			// 访问控制
			if (appConfig && appConfig.hasOwnProperty('common') && appConfig.common.view_client.indexOf(this.clientType) == -1) {
				// 禁止访问跳转到错误页
				return this.$appLaunchReject({
					message: appConfig.common.view_client_disable_help
				});
			}
			// #ifdef H5
			if (this.clientType == 'wechat_mobile' || this.clientType == 'wechat_computer') {
				// 微信客户端
				// 验证登陆信息
				let loginInfo = this.$wx.loginCheckFunc(this.vuex_wx_id);
				// 更新全局信息
				if (loginInfo && (!this.vuex_wx_id || this.vuex_wx_id != loginInfo.id || !this.vuex_wx_token || this.vuex_wx_token != loginInfo.token)) {
					this.$u.vuex('vuex_wx_id', loginInfo.id);
					this.$u.vuex('vuex_wx_token', loginInfo.token);
				}
				console.log('app->vuex_wx_token[缓存微信TOKEN]:', this.vuex_wx_token);
				
				// region 微信SDK +++++
				if (appConfig) {
					let wxJsSdkConfig = await this.$u.api.wxJsSdkConfig({
						wx_id: this.vuex_wx_id,
						wx_sign_link: window.location.href
					});
					if (wxJsSdkConfig) {
						console.log('app->wxShareConfig[微信jssdk配置]:', wxJsSdkConfig);
						this.$wx.sdk.config(JSON.parse(wxJsSdkConfig));
						this.$wx.sdk.ready(() => {
							this.$wx.sdk.hideMenuItems({
								menuList: ['menuItem:share:qq', 'menuItem:share:weiboApp',
									'menuItem:favorite', 'menuItem:share:facebook',
									'menuItem:share:QZone', 'menuItem:copyUrl',
									'menuItem:openWithQQBrowser', 'menuItem:openWithSafari'
								]
							});
							this.$wx.sdk.updateAppMessageShareData({
								title: this.$config.wx_share_title,
								desc: this.$config.wx_share_desc,
								link: this.$config.wx_share_link,
								imgUrl: this.$config.wx_share_image,
								success: function() {
									// 设置成功
								}
							});
							this.$wx.sdk.updateTimelineShareData({
								title: this.$config.wx_share_title,
								link: this.$config.wx_share_link,
								imgUrl: this.$config.wx_share_image,
								success: function() {
									// 设置成功
								}
							});
							// 分享到朋友圈
							this.$wx.sdk.onMenuShareTimeline({
								title: this.$config.wx_share_title,
								link: this.$config.wx_share_link,
								imgUrl: this.$config.wx_share_image,
								success: function() {
									// 用户确认后执行的回调函数
								},
								cancel: function() {
									// 用户取消后执行的回调函数
								}
							});
							//分享给朋友
							this.$wx.sdk.onMenuShareAppMessage({
								title: this.$config.wx_share_title,
								desc: this.$config.wx_share_desc,
								link: this.$config.wx_share_link,
								imgUrl: this.$config.wx_share_image,
								type: 'link',
								dataUrl: '',
								success: function() {
									// 用户确认后执行的回调函数
								},
								cancel: function() {
									// 用户取消后执行的回调函数
								}
							});
						});
					}
				}
				// endregion
			}
			// #endif
			// 初始化完成
			this.$appLaunchResolve(true);
>>>>>>> 53a01f14caa8fe2937e0147169c912d2b7301b5f
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	// 引入uview-ui样式
	@import 'uview-ui/index.scss';
	page, .wo-page {
	    width: 100%;
	    height: 100%;
	}
</style>
